package pri.hillchen.std.concurrent.chapter5;

import java.util.Collection;
import java.util.Vector;

/**
 * @author:hillchen
 * @DESCRIPTION:
 * @Date: Created in 8:46 2018/2/7 0007.
 */
public class NotAtomicDemo {
    public static void main(String[] args){
        final Vector vector = new Vector();
        for(int i=0;i<100;i++){
            vector.add(i);
        }
        Thread removeElement = new RemoveLastElementRunable(vector) {
            void removeElement(Collection collection, int index) {
                collection.remove(index);
            }
        };

        Thread printElement = new PrintElementRunable(vector) {
            void printlnElement(Object o) {
                System.out.println(o);
            }
        };

        removeElement.start();
        printElement.start();
    }
}
